<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>Document</title>
</head>

<body>
  <script>
    // proxy vue3 的响应式原理
    const user = {
      name: '佐助',
      age: 20,
      wife: {
        name: '小薇',
        age: 19,
      },
    }
    //变成代理对象
    const proxyUser = new Proxy(user, {
      get(target, props) {
        console.log('get方法调用了')
        return Reflect.get(target, props)
      },
      set(target, props, val) {
        console.log('set方法调用了')
        return Reflect.set(target, props, val)
      },
      deleteProperty(target, props) {
        return Reflect.deleteProperty(target, props)
      },
    })
    // delete proxyUser.name
    console.log(proxyUser.name)
  </script>
</body>

</html>